//
//  TTButton.m
//  testForBtn
//
//  Created by zhuo on 16/6/27.
//  Copyright © 2016年 zhuo. All rights reserved.
//

#import "TTButton.h"

@implementation TTButton

-(instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        
        [self setupUI];
    }
    
    return self;
}

- (void)setupUI{
    
    if (!_titleLabel) {
        
        _titleLabel = [[UILabel alloc] initWithFrame:self.bounds];
        [self addSubview:_titleLabel];
    }
    
    if (!_backGroundView) {
        
        _backGroundView = [[UIView alloc] initWithFrame:self.bounds];
        [self addSubview:_backGroundView];
    }
}

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    
    [super touchesBegan:touches withEvent:event];
    NSLog(@"begin");
    self.titleLabel.text = @"1231212122";
}

-(void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    
    NSLog(@"===end");
    self.titleLabel.text = @"你看看了你看反馈是你";
    [super touchesEnded:touches withEvent:event];
}

-(void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    
    NSLog(@"-=-=-=");
    
    UITouch * touch = touches.anyObject;
    
   CGPoint point =  [touch locationInView:self];
    
    NSLog(@"%@",NSStringFromCGPoint(point));

    [super touchesMoved:touches withEvent:event];
}

-(void)touchesCancelled:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    
    NSLog(@"--------cancle");
    [super touchesCancelled:touches withEvent:event];
    
}
@end
